import request from '@/router/axios';
import {downloadExcel} from '@/router/axios';
import {formatCondition} from '@/util/util';
//单条查询
export const queryDynamicForm = (params) => {
  params.head.transCode = 'queryDynamicForm';
  return request({
    url: '/platform/dynamicForm/queryDynamicForm',
    method: 'post',
    data: params
  })
}
//多条列表查询，支持条件查询
export const queryDynamicFormListPage = (params) => {
  params.head.transCode = 'queryDynamicFormListPage';
  return request({
    url: '/platform/dynamicForm/queryDynamicFormListPage',
    method: 'post',
    data: params
  })
}
//新增单条记录
export const saveDynamicForm = (params) => {
  params.head.transCode = 'saveDynamicForm';
  return request({
    url: '/platform/dynamicForm/saveDynamicForm',
    method: 'post',
    data: params
  })
}
//新增或修改单条记录
export const saveOrUpdateDynamicForm = (params) => {
  params.head.transCode = 'saveOrUpdateDynamicForm';
  return request({
    url: '/platform/dynamicForm/saveOrUpdateDynamicForm',
    method: 'post',
    data: params
  })
}


//新增或修改单条记录
export const saveOrUpdateDynamicFormList = (params) => {
  params.head.transCode = 'saveOrUpdateDynamicFormList';
  return request({
    url: '/platform/dynamicForm/saveOrUpdateDynamicFormList',
    method: 'post',
    data: params
  })
}

//修改单条记录
export const updateDynamicForm = (params) => {
  params.head.transCode = 'updateDynamicForm';
  return request({
    url: '/platform/dynamicForm/updateDynamicForm',
    method: 'post',
    data: params
  })
}

//删除单条记录
export const deleteDynamicForm = (params) => {
  params.head.transCode = 'deleteDynamicForm';
  return request({
    url: '/platform/dynamicForm/deleteDynamicForm',
    method: 'post',
    data: params
  })
}

//删除多条记录
export const deleteDynamicFormList = (params) => {
  params.head.transCode = 'deleteDynamicFormList';
  return request({
    url: '/platform/dynamicForm/deleteDynamicFormList',
    method: 'post',
    data: params
  })
}
//导出excel
export const exportDynamicFormExcel = (params) => {
  downloadExcel({
    url: '/platform/dynamicForm/excelDownload/exportDynamicFormExcel',
    method: 'get',
    data: 
    {
      tenantId: params.head.tenantId,
      bizCode: params.body.singleBody.bizCode,
      formId: params.body.singleBody.formId,
      orders:'',
      condition: formatCondition(params.body.sqlCondition)
    }
  })
}
